import { ref, reactive } from 'vue'
import { IRoles } from '@/types/systemManage'
import type { FormRules, FormInstance } from 'element-plus'

export default function (dialogRef: any, dialogFormRef?: any) {
  const dialogForm = ref<IRoles>({
    roleKey: '',
    roleName: '',
    roleId: 0,
    order: 0,
    status: '1'
  })
  const dialogOptions = reactive({
    title: '新增角色',
    width: '420px',
    openType: 1
  })
  const dialogFormRules = reactive<FormRules>({
    roleKey: [
      { required: true, message: '请输入权限字符', trigger: 'blur' }
    ],
    roleName: [
      { required: true, message: '角色名称', trigger: 'blur' }
    ],
    roleId: [
      { required: true, message: '角色ID', trigger: 'change' }
    ],
    order: [
      { required: true, message: '角色排序', trigger: 'change' }
    ],
    status: [
      { required: true, message: '选择角色状态', trigger: 'change' }
    ]
  })

  const defaultProps = {
    children: 'children',
    label: 'label'
  }
  interface Tree {
    menuId: number
    label: string
    children?: Tree[]
  }
  const treeData = ref<Tree[]>()
  return {
    dialogForm,
    dialogOptions,
    dialogFormRules,
    defaultProps,
    treeData
  }
}
